package com.example.spring_security.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author Mr.Hu
 * @since 2021-07-02 15:00
 */
@Controller
public class RouterController {
  // 使得访问/,/index,/index.html都能跳到主页
  @RequestMapping({"/", "/index", "/index.html"})
  public String index() {
    return "index";
  }

  @RequestMapping("/toLogin")
  public String toLogin() {
    return "views/login";
  }
  // 实现对level的三个页面的跳转,下面也是如此
  @RequestMapping("/level1/{id}")
  public String level1(@PathVariable("id") int id) {
    return "views/level1/" + id;
  }

  @RequestMapping("/level2/{id}")
  public String level2(@PathVariable("id") int id) {
    return "views/level2/" + id;
  }

  @RequestMapping("/level3/{id}")
  public String level3(@PathVariable("id") int id) {
    return "views/level3/" + id;
  }
}
